import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('127.0.0.1'))
channel = connection.channel()

channel.exchange_declare(exchange='logs',  # 交换机名称
                         exchange_type='fanout')  # 模式---发布订阅

message = 'info: Hello World'
channel.basic_publish(exchange='logs',  # 指定交换机
                      routing_key='',
                      body=message)

print(" [x] Sent %r" % message)
connection.close()


